/*
 * @Author: gyc
 * @Date: 2020-04-09 13:30:28
 * @LastEditTime: 2020-05-22 09:05:39
 * @Description: 测试版
 */
const Koa = require('koa')
const app = new Koa()
const db = require("./config/oracledb.js")

//跨域支持cookie
app.use(async (ctx, next) => {
    ctx.set('Access-Control-Allow-Credentials', 'true')
    ctx.set('Access-Control-Allow-Origin', ctx.headers["origin"] || '*');
    ctx.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
    ctx.set('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
    ctx.set('Content-Type', 'application/json;charset=utf-8')
    if (ctx.method == 'OPTIONS') {
        ctx.body = 200;
    } else {
        await next();
    }
});

app.use(async (ctx) => {
    //查询SQL
    const a = await db.query("SELECT sfaadocno,sfaastus  FROM sfaa_t where sfaadocno='MMOB-20010038' or sfaadocno='MMOB-20010039'")
    ctx.body = a
    // ctx.body = await getResult()

});
app.listen(3001)
console.log('[demo] start-quick is starting at port 3001')